package com.fromfuture.xuhuidoc.android.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.fromfuture.xuhuidoc.R;
import com.fromfuture.xuhuidoc.cordova.callback.OnImageSuccessListener;
import com.fromfuture.xuhuidoc.cordova.untils.ImageTask;

public class ImageActivity extends AppCompatActivity {

    ImageView imageView;
    Bitmap bitmap;
    String url;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image);
        imageView= (ImageView) findViewById(R.id.imageActivity_img);
        Intent intent=getIntent();
        bitmap=intent.getParcelableExtra("bitmap");
        url=intent.getStringExtra("imgurl");
        if (bitmap!=null){
            imageView.setImageBitmap(bitmap);
        }else if (url!=null){
            ImageTask imageTask =new ImageTask(new OnImageSuccessListener() {
                @Override
                public void onImageSuccess(Bitmap bitmap) {
                    imageView.setImageBitmap(bitmap);
                }
            });
            imageTask.execute(url);
        }

    }
}
